package cn.tedu.com.enums;

import java.io.Serializable;

public enum  ReturnCode {
    SUCCESS(200,"success"),
    BUSINESS_EXCEPTION(999,"业务异常"),
    LOGIN_FAIL(300,"登录失败"),
    SERVER_EXCEPION(500,"服务异常"),
    ;
    private Integer code;
    private String messge;

    ReturnCode(Integer code, String messge) {
        this.code = code;
        this.messge = messge;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessge() {
        return messge;
    }

    public static ReturnCode getEnum(Integer code){
        ReturnCode[] values = values();
        if(values.length>0){
            for(ReturnCode rc:values){
                if(code.equals(rc.getCode())){
                    return  rc;
                }
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "ReturnCode{" +
                "code=" + code +
                ", messge='" + messge + '\'' +
                "} ";
    }
}
